home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / SNNSV32.ZIP / SNNSv3.2 / xgui / sources / d3_project.c < prev    next >
Encoding:
C/C++ Source or Header  |  1994-04-25  |  6.3 KB  |  216 lines

  1. /*****************************************************************************
  2.   FILE           : d3_project.c
  3.   SHORTNAME      : project.c
  4.   SNNS VERSION   : 3.2
  5.  
  6.   PURPOSE        : controls the project pannel
  7.   NOTES          :
  8.  
  9.   AUTHOR         : Ralf Huebner
  10.   DATE           : 1.12.1991
  11.  
  12.   CHANGED BY     :
  13.   IDENTIFICATION : @(#)d3_project.c    1.10 3/2/94
  14.   SCCS VERSION   : 1.10
  15.   LAST CHANGE    : 3/2/94
  16.  
  17.              Copyright (c) 1990-1994  SNNS Group, IPVR, Univ. Stuttgart, FRG
  18.              
  19. ******************************************************************************/
  20.  
  21.  
  22. #include <stdio.h>
  23. #include <memory.h>
  24.  
  25. #include <X11/Xlib.h>
  26. #include <X11/Xutil.h>
  27. #include <X11/Intrinsic.h>
  28. #include <X11/StringDefs.h>
  29. #include <X11/Shell.h>
  30. #include <X11/Xaw/Simple.h>
  31. #include <X11/Xaw/Box.h>
  32. #include <X11/Xaw/Form.h>
  33. #include <X11/Xaw/Toggle.h>
  34.  
  35. #include "glob_typ.h"
  36. #include "ui.h"
  37. #include "ui_xWidgets.h"
  38. #include "d3_global.h"
  39. #include "d3_xUtils.h"
  40. #include "d3_main.h"
  41.  
  42. #include "d3_project.ph"
  43.  
  44.  
  45. /*****************************************************************************
  46.   FUNCTION : d3_closeProjectPannel
  47.  
  48.   PURPOSE  : close the project pannel
  49.   RETURNS  : void
  50.   NOTES    :
  51.  
  52.   UPDATE   :
  53. ******************************************************************************/
  54.  
  55. static void d3_closeProjectPannel (Widget w, Widget pannel, caddr_t call_data)
  56.  
  57. {
  58.     temp_state.viewpoint [0] = ui_xFloatFromAsciiWidget (viewpointXwidget);
  59.     temp_state.viewpoint [1] = ui_xFloatFromAsciiWidget (viewpointYwidget);
  60.     temp_state.viewpoint [2] = ui_xFloatFromAsciiWidget (viewpointZwidget);
  61.     XtDestroyWidget (pannel);
  62.     if (memcmp (&d3_state, &temp_state, 
  63.                 sizeof (d3_state_type)) != 0) {
  64.          memcpy (&d3_state, &temp_state, 
  65.                  sizeof (d3_state_type)); 
  66.          d3_drawNet ();
  67.     }
  68. }
  69.  
  70.  
  71. /*****************************************************************************
  72.   FUNCTION : setProjectToggleState
  73.  
  74.   PURPOSE  : sets the toggles in the project pannel
  75.   RETURNS  : void
  76.   NOTES    :
  77.  
  78.   UPDATE   :
  79. ******************************************************************************/
  80.  
  81. static void setProjectToggleState (void)
  82.  
  83. {
  84.     switch (temp_state.projection_mode)
  85.       {
  86.         case parallel: ui_xSetToggleState (parallelButton, TRUE);
  87.                        ui_xSetToggleState (centralButton, FALSE);
  88.                        break;
  89.         case central : ui_xSetToggleState (parallelButton, FALSE);
  90.                        ui_xSetToggleState (centralButton, TRUE);
  91.                        break;
  92.       }
  93. }
  94.  
  95.  
  96. /*****************************************************************************
  97.   FUNCTION : setParallelProjection
  98.  
  99.   PURPOSE  : sets mode to display the net with parallel projection
  100.   RETURNS  : void
  101.   NOTES    :
  102.  
  103.   UPDATE   :
  104. ******************************************************************************/
  105.  
  106. static void setParallelProjection (void)
  107.  
  108. {
  109.     temp_state.projection_mode = parallel;
  110.     setProjectToggleState ();
  111. }
  112.  
  113.  
  114. /*****************************************************************************
  115.   FUNCTION : setCentralProjection
  116.  
  117.   PURPOSE  : sets mode to display the net with central projection
  118.   RETURNS  : void
  119.   NOTES    :
  120.  
  121.   UPDATE   :
  122. ******************************************************************************/
  123.  
  124. static void setCentralProjection (void)
  125.  
  126. {
  127.     temp_state.projection_mode = central;
  128.     setProjectToggleState ();
  129. }
  130.  
  131.  
  132. /*****************************************************************************
  133.   FUNCTION : createProjectPannel
  134.  
  135.   PURPOSE  : creates the project pannel
  136.   RETURNS  : void
  137.   NOTES    :
  138.  
  139.   UPDATE   :
  140. ******************************************************************************/
  141.  
  142. void d3_createProjectPannel (Widget w, Widget button, caddr_t call_data)
  143.  
  144. {
  145.     int n;
  146.     Arg arg[10];
  147.     char buf[20];
  148.     Position xPos, yPos;
  149.     Dimension width, height;
  150.     Widget projectPannel, pannel, border, label, done;
  151.  
  152.     n = 0;
  153.     XtSetArg (arg[0], XtNwidth, &width); n++;
  154.     XtSetArg (arg[1], XtNheight, &height); n++;
  155.     XtGetValues (button, arg, (unsigned int) n);
  156.  
  157.     XtTranslateCoords (button, (Position) (width / 2), (Position) (height / 2), &xPos, &yPos);
  158.  
  159.     n = 0;
  160.  
  161.     XtSetArg(arg[n], XtNx, xPos); n++;
  162.     XtSetArg(arg[n], XtNy, yPos); n++;
  163.  
  164.     projectPannel = XtCreatePopupShell ("projection", transientShellWidgetClass, button, arg, (unsigned int) n);
  165.  
  166.     border = XtCreateManagedWidget("border", boxWidgetClass,
  167.                                    projectPannel, NULL, ZERO);
  168.     pannel = XtCreateManagedWidget("pannel", formWidgetClass, 
  169.                                    border, NULL, ZERO);
  170.  
  171.     parallelButton = d3_xCreateToggleItem ("parallel", pannel, NULL, NULL, NULL);
  172.     centralButton = d3_xCreateToggleItem ("central", pannel, NULL,
  173.                                    parallelButton, NULL);
  174.  
  175.     label = ui_xCreateLabelItem ("  Viewpoint  X", pannel, d3_fontWidth * 14,
  176.                                    NULL, centralButton); 
  177.  
  178.     sprintf (buf, "%.4f", d3_state.viewpoint[0]);
  179.     viewpointXwidget = ui_xCreateDialogItem ("viewpointX", pannel,
  180.                                    buf, d3_numberWidth, label, centralButton);
  181.  
  182.     label = ui_xCreateLabelItem ("             Y", pannel,  d3_fontWidth * 14,
  183.                                    NULL, label); 
  184.  
  185.     sprintf (buf, "%.4f", d3_state.viewpoint[1]);
  186.     viewpointYwidget = ui_xCreateDialogItem ("viewpointY", pannel,
  187.                                 buf, d3_numberWidth, label, viewpointXwidget);
  188.  
  189.     label = ui_xCreateLabelItem ("             Z", pannel, d3_fontWidth * 14,
  190.                                    NULL, label); 
  191.  
  192.     sprintf (buf, "%.4f", d3_state.viewpoint[2]);
  193.     viewpointZwidget = ui_xCreateDialogItem ("viewpointX", pannel,
  194.                                    buf, d3_numberWidth, label, viewpointYwidget);
  195.  
  196.     done = d3_xCreateButtonItem ("done", border, NULL, label);
  197.  
  198.  
  199.     XtAddCallback (parallelButton, XtNcallback, (XtCallbackProc) setParallelProjection, NULL);
  200.     XtAddCallback (centralButton, XtNcallback, (XtCallbackProc) setCentralProjection, NULL);
  201.     XtAddCallback (done, XtNcallback, (XtCallbackProc) d3_closeProjectPannel,
  202.                    (Widget) projectPannel);
  203.  
  204.     memcpy (&temp_state, &d3_state, sizeof (d3_state_type)); 
  205.  
  206.     setProjectToggleState ();
  207.   
  208.     ui_checkWindowPosition(projectPannel);
  209.     XtPopup (projectPannel, XtGrabExclusive);
  210.     ui_xDontResizeWidget(projectPannel); 
  211.  
  212. }
  213.  
  214. /* end of file */
  215. /* lines: 233 */
  216.